<?php

	session_start();
	require_once('../config.php');
	include_once("../database/DataBase.php");
	include_once("function.php");

	$lid = $_POST["lid"];
	$area = $_POST["area"];
	$location_name = $_POST["location_name"];
	
	$database = New DataBase();
	$database->open_connection();
	$result = $database->updateLocation($lid, $location_name, $area);
	
	if(!is_null($result)){
		$database->LogAction($_SESSION["login_id"], "Update", "Update new location from ".getIpAddress());
		$_SESSION["message"] = "Update location success.";
		header('Location: ../Message.php');
	}
	else{
		$_SESSION["message"] = "Update location (".$location_name.") fail.";
		header('Location: ../Message.php');
	}
	
	$database->close_connection();
?>
